#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    int *a = (int *)malloc(n * sizeof(int));
    if(!a){
        exit(0);
    }
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    int maxlen = 1, maxidx = 0, len = 1, idx = 0;
    //find the longest subsequence
    for (i = 1; i < n; i++) {
        if (a[i] > a[i - 1]) {
            len++;
        } else {
            if (len > maxlen) {
                maxlen = len;
                maxidx = idx;
            }
            len = 1;
            idx = i;
        }
    }
    //examine the subsequence if right
    if (len > maxlen) {
        maxlen = len;
        maxidx = idx;
    }
    for (i = maxidx; i < maxidx + maxlen; i++) {
        printf("%d", a[i]);
        if (i < maxidx + maxlen - 1) {
            printf(" ");
        }
    }
    return 0;
}